//
//  BaseTableViewCell.m
//  Demo
//
//  Created by colawh on 2019/3/13.
//  Copyright © 2019年 colawhdfws. All rights reserved.
//

#import "BaseTableViewCell.h"
#import "DemoHelp.h"
@interface BaseTableViewCell ()

@property (nonatomic,strong) UIView *bottomView;

@property (nonatomic,strong) UIView *topView;

@property (nonatomic,strong) UIView *leftLineView;

@property (nonatomic,strong) UILabel *titleLb;

@end


@implementation BaseTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self conbsfigUI];
    }
    return self;
}
//子类覆盖
- (CGFloat)realHeight{
    return 10;
}
- (void)setTitile:(NSString *)titile{
    _titile = titile;
    _titleLb.text = _titile;
}
- (void)conbsfigUI{
    [self.contentView addSubview:self.topView];
    [self.topView addSubview:self.leftLineView];
    [self.topView addSubview:self.titleLb];
    [self.contentView addSubview:self.bottomView];
}
- (void)layoutSubviews{
    [super layoutSubviews];
    CGFloat gap = 15;
    CGFloat topHeight = 50;
    [_topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(self.contentView);
        make.height.mas_equalTo(topHeight);
    }];
    [_leftLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(3, 14));
        make.left.mas_equalTo(gap);
        make.centerY.equalTo(_topView);
    }];
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(_topView);
        make.left.equalTo(_leftLineView.mas_right).offset(5);
        make.right.equalTo(_topView).offset(-gap);
    }];
    [_bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.contentView);
        make.top.equalTo(_topView.mas_bottom);
    }];
}
//- (CGFloat)realHeight{
//    return 50;
//}
- (UIView *)topView{
    if (!_topView) {
        _topView = [UIView new];
    }
    return _topView;
}
- (UIView *)bottomView{
    if (!_bottomView) {
        _bottomView = [UIView new];
    }
    return _bottomView;
}
- (UIView *)leftLineView{
    if (!_leftLineView) {
        _leftLineView = [UIView new];
        _leftLineView.backgroundColor = kUIColorFromRGB(0x0085FE);
    }
    return _leftLineView;
}
- (UILabel *)titleLb{
    if (!_titleLb) {
        _titleLb = [DemoHelp getLbByFont:12];
        _titleLb.textColor = kUIColorFromRGB(0x091522);
        
    }
    return _titleLb;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
